Scaffold::Application.routes.draw do
  devise_for :users, skip: [:registrations], controllers: {sessions: 'common/sessions'}
  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  root 'admin/users#index'
  get 'admin' => 'admin/users#index'
  namespace :front do |front|

    resources :contacts do
      collection do
        get :upload
        post :upload_file
        get :tree_data, format: 'json'
      end
    end

    get 'users/edit' => 'users#edit'
    patch 'users/update' => 'users#update'
    get 'users/update_password' => 'users#update_password'
    patch 'users/update_password' => 'users#update_password'
    resources :user_bills, only: [:index, :show]
  end

  namespace :admin do |admin|

    get 'roles/tree_data/:type' => 'roles#tree_data'
    post 'roles/destroy_multi' => 'roles#destroy_multi'
    post 'users/destroy_multi' => 'users#destroy_multi'
    post 'permissions/destroy_multi' => 'permissions#destroy_multi'
    post 'organizations/destroy_multi' => 'organizations#destroy_multi'
    post 'code_tables/destroy_multi' => 'code_tables#destroy_multi'
    post 'attachments/destroy_multi' => 'attachments#destroy_multi'
    post 'process_defines/destroy_multi' => 'process_defines#destroy_multi'
    post 'process_instances/destroy_multi' => 'process_instances#destroy_multi'
    post 'process_active_instances/destroy_multi' => 'process_active_instance#destroy_multi'
    post 'process_tasks/destroy_multi' => 'process_tasks#destroy_multi'
    resources :roles
    resources :attachments
    resources :code_tables
    resources :organizations
    resources :permissions
    resources :process_defines
    resources :process_instances
    resources :process_active_instances
    resources :process_tasks
    resources :users do
      collection do
        get 'validate_user'
        get 'update_password'
        patch 'update_password'
      end
    end
    namespace :engines do
      get 'deal_with/:process_task_id', action: 'deal_with'
      get 'usertask1'
      get 'usertask2'
      get 'usertask3'
      get 'usertask4'
      get 'usertask5'
      post 'usertask1'
      post 'usertask2', action: 'usertask1_post'
      post 'usertask3', action: 'usertask1_post'
      post 'usertask4', action: 'usertask1_post'
      post 'usertask5', action: 'usertask1_post'
    end
    namespace :process_defines do
      get ':id/create_instance', action: 'create_instance'
    end
  end

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
end
